package NC;

public class NC19 {
    public int maxsumofSubarray (int[] arr) {
        // write code here
        if(arr.length==0) return 0;
        int temp = arr[0];
        int ans = arr[0];
        for (int i = 1; i <arr.length; i++) {
            temp = arr[i]+temp>0?arr[i]+temp:arr[i];
            ans= Math.max(ans,temp);
        }
        return ans;
    }
}
